#include"huffman.h"
void main()
{
    clock_t begin, end;
    double cost;
    FILE* fp;
    char ch;
    int ret1, ret2;
    memset(&TreeNode, 0, sizeof(TreeNode));
    memset(&tmp, 0, sizeof(tmp));
    ret1 = compress("data.txt", "data.zip.txt");
    //开始记录
    begin = clock();
    ret2 = uncompress("data.zip.txt", "data.unzip.txt");
    //结束记录
    end = clock();
    cost = (double)(end - begin) / CLOCKS_PER_SEC;
    printf("解压缩耗时: %lf secs\n", cost);
    printf("压缩比率是%.3lf%%\n", ((double)ret1 / ret2)*100);
    printf("读取解压后的文件：\n");
    if ((fp = fopen("data.unzip.txt", "rt")) == NULL) {
        printf("读取失败！\n");
        exit(1);
    }
    ch = fgetc(fp);
    while (ch != EOF) {
        putchar(ch);
        ch = fgetc(fp);
    }
    fclose(fp);
}